import React from 'react';
import { withRouter } from 'react-router-dom';
import loadjs from 'loadjs';
import Store from './CKRichEditorStore';

@withRouter
export default class RichText extends React.Component {
  static Store = Store;
  componentDidMount() {
    const init = () => this.props.store.createEditor('editorContanier', this.props);
    loadjs.isDefined('ckeditorJS') ? loadjs.ready('ckeditorJS', init) :
      loadjs('/cloudstore/resource/pc/ckeditor-4.6.2/ckeditor.js', 'ckeditorJS', init);
  }
  
  render() {
    return (
      <div id="editorContanier" ref="editor" />
    );
  }
}